#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->lcdNumber->display(QString().setNum(num));
    QTimer* timer = new QTimer(this);
    connect(timer,&QTimer::timeout,this,&Widget::handleTime);
    timer->start(500);
}
Widget::~Widget()
{
    delete ui;
}

void Widget::handleTime()
{
   if(num == 0)
       Widget::close();
   ui->lcdNumber->display(QString().setNum(--num));
}

